package org.agile2soft.nexoma.expedient.entity;

import java.util.HashSet;
import java.util.Set;
import javax.persistence.AttributeOverride;
import javax.persistence.AttributeOverrides;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import org.agile2soft.nexoma.core.entity.Profile;

@Entity
@Table(name = "EXPEDIENT_TYPE_PHASES")
@SuppressWarnings({"serial"})
public class ExpedientTypePhase implements java.io.Serializable {

    private ExpedientTypePhaseId id;
    private ExpedientPhase phase;
    private ExpedientType expedientType;
    private Boolean nextOk;
    private Boolean nextKo;
    private String nameOk;
    private String nameKo;
    private Boolean nextFixed;
    private Set<Profile> profiles = new HashSet<Profile>(0);

    public ExpedientTypePhase() {
    }

    public ExpedientTypePhase(ExpedientTypePhaseId id, ExpedientPhase phase,
            ExpedientType expedientType) {
        this.id = id;
        this.phase = phase;
        this.expedientType = expedientType;
    }

    public ExpedientTypePhase(ExpedientTypePhaseId id, ExpedientPhase phase,
            ExpedientType expedientType, Boolean nextOk,
            Boolean nextKo, String nameOk, String nameKo,
            Boolean nextFixed, Set<Profile> profiles) {
        this.id = id;
        this.phase = phase;
        this.expedientType = expedientType;
        this.nextOk = nextOk;
        this.nextKo = nextKo;
        this.nameOk = nameOk;
        this.nameKo = nameKo;
        this.nextFixed = nextFixed;
        this.profiles = profiles;
    }

    @EmbeddedId
    @AttributeOverrides( {
            @AttributeOverride(name = "phaseId", column = @Column(name = "FAS_ID", nullable = false)),
            @AttributeOverride(name = "expedientTypeId", column = @Column(name = "TEX_ID", nullable = false)) })
    public ExpedientTypePhaseId getId() {
        return this.id;
    }

    public void setId(ExpedientTypePhaseId id) {
        this.id = id;
    }

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "FAS_ID", nullable = false, insertable = false, updatable = false)
    public ExpedientPhase getPhase() {
        return this.phase;
    }

    public void setPhase(ExpedientPhase phase) {
        this.phase = phase;
    }

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "TEX_ID", nullable = false, insertable = false, updatable = false)
    public ExpedientType getExpedientType() {
        return this.expedientType;
    }

    public void setExpedientType(ExpedientType expedientType) {
        this.expedientType = expedientType;
    }

    @Column(name = "TFA_NEXT_OK")
    public Boolean getNextOk() {
        return this.nextOk;
    }

    public void setNextOk(Boolean nextOk) {
        this.nextOk = nextOk;
    }

    @Column(name = "TFA_NEXT_KO")
    public Boolean getNextKo() {
        return this.nextKo;
    }

    public void setNextKo(Boolean nextKo) {
        this.nextKo = nextKo;
    }

    @Column(name = "TFA_NAME_OK", length = 250)
    public String getNameOk() {
        return this.nameOk;
    }

    public void setNameOk(String nameOk) {
        this.nameOk = nameOk;
    }

    @Column(name = "TFA_NAME_KO", length = 250)
    public String getNameKo() {
        return this.nameKo;
    }

    public void setNameKo(String nameKo) {
        this.nameKo = nameKo;
    }

    @Column(name = "TFA_NEXT_FIXED")
    public Boolean getNextFixed() {
        return this.nextFixed;
    }

    public void setNextFixed(Boolean nextFixed) {
        this.nextFixed = nextFixed;
    }

    @ManyToMany(fetch = FetchType.LAZY, mappedBy = "expedientTypePhases")
    public Set<Profile> getProfiles() {
        return this.profiles;
    }

    public void setProfiles(Set<Profile> profiles) {
        this.profiles = profiles;
    }

}
